/*
 * @Author: your name
 * @Date: 2022-01-31 15:18:29
 * @LastEditTime: 2022-02-01 17:08:22
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue3-ts-food-admin\vite.config.ts
 */
import { defineConfig } from "vite";
import path from "path";
import vue from "@vitejs/plugin-vue";
import { viteMockServe } from "vite-plugin-mock";

// https://vitejs.dev/config/
export default ({ command }) => {
  return {
    plugins: [
      vue(),
      viteMockServe({
        supportTs: true,
        watchFiles: true,
        mockPath: "./mock",
        localEnabled: command === "serve",
        prodEnabled: command !== "serve",
        injectCode: `
          import { setupProdMockServer } from '../mock/createProductionServer';
          setupProdMockServer();
        `,
      }),
    ],
    server: {
      port: 8611,
      open: true,
    },
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "src"),
      },
    },
  };
};
